package com.ghost.alibabaghost.dao.mapper.sys;

import com.ghost.alibabaghost.dao.dataobject.sys.GhostDeptDO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author yaolisheng
 * @version 1.0
 * @date 2022/1/24 05:07
 */
@Mapper
public interface GhostDeptMapper {

    /**
     * 根據部門編碼查詢
     *
     * @param deptCode
     * @return
     */
    @Select("select id,dept_name,dept_code,parent_code from ghost_dept where dept_code = #{deptCode}")
    GhostDeptDO queryByDeptCode(String deptCode);

    /**
     * 查詢全部
     *
     * @return
     */
    @Select("select id,dept_name,dept_code,parent_code from ghost_dept")
    List<GhostDeptDO> queryAll();

    /**
     * 插入
     *
     * @param ghostDeptDO
     * @return
     */
    @Insert("insert into ghost_dept " +
            "(dept_name,dept_code,parent_code)values " +
            "(#{deptName},#{deptCode},#{parentCode})")
    Integer insertDept(GhostDeptDO ghostDeptDO);

    /**
     * 更新
     *
     * @param ghostDeptDO
     * @return
     */
    @Update("update  ghost_dept set " +
            "dept_name =#{deptName}, dept_code = #{deptCode},parent_code = #{parentCode)" +
            " where dept_code = #{deptCode}")
    Integer updateDeptByCode(GhostDeptDO ghostDeptDO);


}
